﻿<Window x:Class="Adastra.RichEditorLibrary.TablePropertiesDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:Microsoft.WPFControlsLibrary;assembly=WPFControlsLibrary" 
    Title="Tabulka" Height="450" Width="450">
    <!-- -->
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources\Styles\MainViewStyles.xaml"/>


            </ResourceDictionary.MergedDictionaries>

            <!-- NumricEditorStyle -->
            <Style x:Key="NumricEditorStyle" TargetType="{x:Type controls:ValueEditor}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:ValueEditor}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.5*"/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <controls:NumberTextBox x:Name="PART_EDITOR" Style="{DynamicResource NumricTextBoxStyle}" Text="{Binding Path=Value, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Grid.ColumnSpan="2"/>
                                <Rectangle x:Name="PART_DRAGGER"  Stroke="Transparent" Fill="Transparent" />
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True" SourceName="PART_DRAGGER">
                                    <Setter Property="Cursor" Value="SizeAll"/>
                                </Trigger>
                                <Trigger Property="IsDragging" Value="True">
                                    <Setter Property="Cursor" Value="SizeAll"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <Grid.Resources>
            <Style TargetType="{x:Type ToggleButton}" x:Key="PicRes">
                <Setter Property="Width" Value="42"></Setter>
                <Setter Property="Height" Value="38"></Setter>
            </Style>
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="276*" />
            <RowDefinition Height="35" />
        </Grid.RowDefinitions>
        <TabControl Grid.Row="0" x:Name="m_tabbedWorkspace" Margin="1,1,1,1" >
            <TabItem x:Name="m_tabProperties" Header="Základní vlastnosti" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <GroupBox Header="Vzhled tabulky" Grid.Row="0" BorderThickness="0.2">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="0"/>
                                <RowDefinition Height="30"/>
                            </Grid.RowDefinitions>
                            <Label Grid.Column="0" Grid.Row="0" Content="Řádků" Margin="10,0,0,0" Foreground="Black"/>
                            <!--TextBox Grid.Column="1" Grid.Row="0" Name="m_txBxRows" Text="{Binding Path=Rows, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                                     Height="21" Width="107" Margin="10,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/-->
                            <controls:ValueEditor  Name="m_txBxRows" Height="20" Width="107" Margin="10,5,0,0" Grid.Column="1" Grid.Row="0"
                                                        Style="{DynamicResource NumricEditorStyle}"
                                                        Value="{Binding Path=Rows, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                                        LargeChange="2" HorizontalAlignment="Left" VerticalAlignment="Top"
                                                        MaxPrecision="0"
                                                        Minimum="0"
                                                        SmallChange="1"
                                                        DefaultChange="1"/>


                            <Label Grid.Column="0" Grid.Row="1" Content="Sloupců" Margin="10,0,0,0" Foreground="Black"/>
                            <!--TextBox Grid.Column="1" Grid.Row="1" Name="m_txBxColumns" Text="{Binding Path=Columns, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                                     Height="21" Width="107" Margin="10,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/-->
                            <controls:ValueEditor  Name="m_txBxColumns" Height="20" Width="107" Margin="10,5,0,0" Grid.Column="1" Grid.Row="1"
                                                        Style="{DynamicResource NumricEditorStyle}"
                                                        Value="{Binding Path=Columns, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                                        LargeChange="2" HorizontalAlignment="Left" VerticalAlignment="Top"
                                                        MaxPrecision="0"
                                                        Minimum="0"
                                                        SmallChange="1"
                                                        DefaultChange="1"/>

                            <Label Grid.Column="0" Visibility="Hidden" Grid.Row="2"  Content="Barva pozadí:" Foreground="Black" Margin="10,0,0,0" />
                            <ComboBox Grid.Column="1" Visibility="Hidden" Grid.Row="2" Width="107" Margin="10,0,0,0" Height="23" Name="m_comboBackColor" Text="Arial" HorizontalAlignment="Left" IsEnabled="False" />

                            <Label Grid.Column="0" Grid.Row="3"  Content="Šířka sloupce:" Foreground="Black" Margin="10,0,0,0" />
                            <StackPanel Grid.Column="1" Grid.Row="3" Orientation="Horizontal">
                                <controls:ValueEditor  Name="m_txtCellWidth" Height="20" Width="107" Margin="10,0,0,0" 
                                                        Style="{DynamicResource NumricEditorStyle}"
                                                        Value="{Binding Path=CellWidth, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                                        LargeChange="10"
                                                        MaxPrecision="2"
                                                        Minimum="0"
                                                        SmallChange="5"
                                                        DefaultChange="1" />
                                <CheckBox Name="m_chBxAutoCellWidth" Margin="10,0,0,0" IsChecked="{Binding Path=IsCellWidthAutomatic, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                          HorizontalAlignment="Center" VerticalAlignment="Center" Content="Automatická"/>
                            </StackPanel>
                        </Grid>
                    </GroupBox>
                    <GroupBox Header="Okraje" Grid.Row="1" BorderThickness="0.2">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="40"/>
                            </Grid.RowDefinitions>

                            <StackPanel Grid.Row="0" Orientation="Horizontal">
                                <ToggleButton  Style="{StaticResource PicRes}" IsChecked="{Binding Path=IsNoBorder, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                                    <Image Source="..\Resources\NoBorders.png"></Image>
                                </ToggleButton>
                                <Label Content="Žádné" Foreground="Black"/>
                            </StackPanel>

                            <StackPanel Grid.Row="1" Orientation="Horizontal">
                                <ToggleButton  Style="{StaticResource PicRes}" IsChecked="{Binding Path=IsBoxBorder, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                                    <Image Source="..\Resources\BoxBorder.png"></Image>
                                </ToggleButton>
                                <Label Content="Rámeček" Foreground="Black"/>
                            </StackPanel>

                            <StackPanel Grid.Row="2" Orientation="Horizontal">
                                <ToggleButton  Style="{StaticResource PicRes}" IsChecked="{Binding Path=IsFullBorder, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                                    <Image Source="..\Resources\AllBorders.png"></Image>
                                </ToggleButton>
                                <Label Content="Všechny" Foreground="Black"/>
                            </StackPanel>

                            <!-- Border width -->
                            <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
                                <Label Content="Šířka okraje:" Foreground="Black" Margin="5,0,0,5" HorizontalAlignment="Right"/>
                                <ComboBox Margin="2,2,2,2" Width="107" Height="23" Name="m_comboBorderWidth" Text="Arial"  HorizontalAlignment="Right" IsEnabled="False">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="{Binding WidthInfo}" Width="20" />
                                                <ContentControl Content="{Binding Shape}" Width="auto" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                            </StackPanel>

                            <!-- Border color -->
                            <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
                                <Label Content="Barva okraje:" Foreground="Black" Margin="5,0,0,5" HorizontalAlignment="Right"/>
                                <ComboBox Margin="2,2,2,2" Width="107" Height="23" Name="m_comboBorderColor" Text="Arial"  HorizontalAlignment="Right" IsEnabled="False"/>
                            </StackPanel>

                        </Grid>
                    </GroupBox>
                </Grid>

            </TabItem>
        </TabControl>
        <Button Grid.Row="1" IsCancel="True" Margin="0,5,108,5" HorizontalAlignment="Right" Width="75" Click="OnCancelClick" >Storno</Button>
        <Button Grid.Row="1" IsDefault="True" HorizontalAlignment="Right" Margin="0,5,6,5" Width="75" Click="OnOkClick">OK</Button>

    </Grid>
</Window>
